import request, {requestString} from '../../utils/request'

/**
 * 查询公司列表
 *
 * @param appCode
 * @returns {Promise.<Object>}
 */
export async function queryCompanys({ company, claimStatus, dealt, page }) {
    return request(apiPath.mc + "/api/company", {
        method: 'get',
        data: { company, claimStatus, dealt, page: page.page, size: page.size }
    });
}

/**
 * 新增公司
 *
 * @param params
 * @returns {Promise.<void>}
 */
export async function createCompany({ dataSource }) {
    return requestString(apiPath.mc + "/api/company", {
        method: 'post',
        data: { ...dataSource }
    });
}

/**
 * 修改公司
 *
 * @param params
 * @returns {Promise.<void>}
 */
export async function updateCompany({ dataSource }) {
    return requestString(apiPath.mc + "/api/company", {
        method: 'put',
        data: { ...dataSource }
    });
}



/**
 * 根据id获取公司信息
 * @param id
 * @returns {Promise.<void>}
 */
export async function getCompanyById({ id }) {
    return request(apiPath.mc + "/api/company/" + id, {
        method: 'get'
    });
}



/**
 * 删除客户
 * @param id
 * @returns {Promise.<void>}
 */
export async function deleteCompanyById({ id }) {
    return request(apiPath.mc + "/api/company/" + id, {
        method: 'delete'
    });
}

/**
 * 认领客户
 * @param id
 * @returns {Promise.<void>}
 */
export async function claimCompany({ id }) {
    return request(apiPath.mc + "/api/company/" + id + "/claim", {
        method: 'put'
    });
}

/**
 * 分页查待认领询客户
 * 
 *  @param companyName
 *  @param customerno
 *  @param dealt
 */
export async function getUnClaimCompanyForPage(data) {
    return request(apiPath.mc + "/api/company/unclaim", {
        method: 'get',
        data
    });
}

/**
 * 根据名称或编码查询客户
 * @param id
 * @returns {Promise.<void>}
 */
export async function getListByNameAndCusNo({ nameOrCusNo }) {
    return request(apiPath.mc + "/api/company/nameOrCusNo", {
        method: 'get',
        data: { nameOrCusNo }
    });
}

/**
 * 更改认领状态
 *
 * @param params
 * @returns {Promise.<void>}
 */
export async function updateClaimStatus(data) {
    return request(apiPath.mc + "/api/company/claimStatus", {
        method: 'put',
        data
    });
}

/**
 * 
 * 查询客户公司List
 */
export async function getCompanyList(){
    return request(apiPath.mc + "/api/company/all",{
        method:'get'
    });
}
